-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: 默认值没有添加上单位, 点击事件阻止冒泡 #9204
Conversation
@@ -213,6 +213,10 @@ export default class NumberControl extends React.Component< | |||
} | |||
|
|||
this.state = {unit, unitOptions}; | |||
|
|||
if (unit && value != null) { | |||
setPrinstineValue(this.getValue(value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
补充一下初始值带单位的单测用例
77dbabb
to
3605cdd
Compare
|
||
const staticDom = container.querySelector('.cxd-PlainField') as Element; | ||
|
||
expect(staticDom.innerHTML).toBe('<span class="text-muted">12px</span>'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个判断innerText就够了,不需要关心DOM结构
expect(staticDom.innerHTML).toBe('99px'); | ||
|
||
replaceReactAriaIds(container); | ||
expect(container).toMatchSnapshot(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
后面两行不需要,前面的逻辑检查足够了,不需要快照,测试单位的那个已经覆盖了
726dd8f
to
8ed8125
Compare
@@ -213,6 +213,10 @@ export default class NumberControl extends React.Component< | |||
} | |||
|
|||
this.state = {unit, unitOptions}; | |||
|
|||
if (unit && value != null) { | |||
setPrinstineValue(this.getValue(value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果 value 和 this.getValue(value) 结果一样呢?是不是不应该触发?
请补充这个场景用例 form 配置 initApi,初始不带单位,通过按钮点击后,重新拉取 initApi,也没有带单位,不修改直接提交,这个数值预期应该是要带单位的。 |
c746d08
to
521fde3
Compare
521fde3
to
d2644f8
Compare
unit && | ||
!String(value).endsWith(unit) | ||
) { | ||
this.props.setPrinstineValue(this.getValue(value)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
初步感觉有两个问题
- didMount 没有相关逻辑
- 如果 外部 value 发生变化,而且初始化之后,不应该是 setPrinstineValue 而是 onChange出去
What
Why
默认值未处理单位
阻止冒泡事件
How